

package com.hazelcast.client.impl.protocol.codec.custom;

import com.hazelcast.client.impl.protocol.ClientMessage;
import com.hazelcast.client.impl.protocol.Generated;
import com.hazelcast.client.impl.protocol.codec.builtin.CustomTypeFactory;
import com.hazelcast.client.impl.protocol.codec.builtin.DataCodec;
import com.hazelcast.client.impl.protocol.codec.builtin.ListMultiFrameCodec;

import static com.hazelcast.client.impl.protocol.ClientMessage.BEGIN_FRAME;
import static com.hazelcast.client.impl.protocol.ClientMessage.END_FRAME;
import static com.hazelcast.client.impl.protocol.codec.builtin.CodecUtil.fastForwardToEndFrame;

@SuppressWarnings("unused")
@Generated("522ba97d256923b083e9d7626de2696c")
public final class VectorDocumentCodec {

    private VectorDocumentCodec() {
    }

    public static void encode(ClientMessage clientMessage, com.hazelcast.vector.impl.DataVectorDocument vectorDocument) {
        clientMessage.add(BEGIN_FRAME.copy());

        DataCodec.encode(clientMessage, vectorDocument.getValue());
        ListMultiFrameCodec.encode(clientMessage, vectorDocument.getVectors(), VectorPairCodec::encode);

        clientMessage.add(END_FRAME.copy());
    }

    public static com.hazelcast.vector.impl.DataVectorDocument decode(ClientMessage.ForwardFrameIterator iterator) {
        // begin frame
        iterator.next();

        com.hazelcast.internal.serialization.Data value = DataCodec.decode(iterator);
        java.util.List<com.hazelcast.client.impl.protocol.codec.holder.VectorPairHolder> vectors = ListMultiFrameCodec.decode(iterator, VectorPairCodec::decode);

        fastForwardToEndFrame(iterator);

        return CustomTypeFactory.createVectorDocument(value, vectors);
    }
}
